package com.foreknow.demo7;

/**
 * 静态变量：可以被多个对象共享
 * 作用：可以作为累加器来使用
 */
public class StaticVar {
    public static int i;
    public StaticVar(){
        i++;
        System.out.println(i);
    }

    public  static void main(String[] args){
        StaticVar staticVar = new StaticVar();
        StaticVar staticVar1 = new StaticVar();
        StaticVar staticVar2 = new StaticVar();
        StaticVar staticVar3 = new StaticVar();
        StaticVar staticVar4 = new StaticVar();
        StaticVar staticVar5 = new StaticVar();
        StaticVar staticVar6 = new StaticVar();
        StaticVar staticVar7 = new StaticVar();
        StaticVar staticVar8 = new StaticVar();
        StaticVar staticVar9 = new StaticVar();

    }
}
